//
//  FirstTouchController.m
//  EMMApp
//
//  Created by 无常先生 on 2018/8/20.
//  Copyright © 2018年 YiXun. All rights reserved.
//

#import "FirstTouchController.h"
#import "UIView+Extension.h"
#import "firstTouchCell.h"
#import "FirstTouchHeaderView.h"
#import "FirstTouchFooterView.h"
@interface FirstTouchController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, weak) UITableView *tableView;
@end

static NSString *const cellID = @"cellID";
@implementation FirstTouchController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatNavigationBar];
    
    [self prepareUI];
    
}

- (void)prepareUI{
    
    UITableView *listView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    listView.height -= 80;
    listView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    listView.delegate = self;
    listView.dataSource = self;
    listView.rowHeight = 65;
    listView.tableHeaderView = [FirstTouchHeaderView loadView];
    listView.tableFooterView = [FirstTouchFooterView loadView];
    [listView registerNib:[UINib nibWithNibName:NSStringFromClass([firstTouchCell class]) bundle:nil] forCellReuseIdentifier:cellID];
    [self.view addSubview:listView];
    self.tableView = listView;
    
    UIButton *bottomBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, listView.height, listView.width - 20, 45)];
    bottomBtn.backgroundColor = [UIColor colorFromHexCode:@"#FB5A3B"];
    bottomBtn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    [bottomBtn setTitle:@"保存" forState:UIControlStateNormal];
    bottomBtn.layer.cornerRadius = 4;
    [self.view addSubview:bottomBtn];
    
    
    
    
}


- (void)creatNavigationBar {
    
    self.title = @"首次接触信息";
    self.navigationController.navigationBar.translucent = YES;
    //返回按钮初始化
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setFrame:CGRectMake(0, 0, 54 ,44)];
    [backBtn addTarget:self
                action:@selector(NewbackToPreviousPage)
      forControlEvents:UIControlEventTouchUpInside];
    [backBtn setBackgroundColor:[UIColor clearColor]];
    [backBtn setImage:[UIImage imageNamed:@"ico_back"] forState:UIControlStateNormal];
    backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    if (EMM_WIDTH <= 320) {
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }else if (EMM_WIDTH > 375){
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
    }else{
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
}


- (void)NewbackToPreviousPage {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - delegate & dataSource

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    firstTouchCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    return cell;
}


@end
